package org.ycx.doc.dao.auto;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.ycx.doc.dao.model.DocUserVersion;
import org.ycx.doc.dao.model.DocUserVersionExample;

public interface DocUserVersionMapper {
    @SelectProvider(type=DocUserVersionSqlProvider.class, method="countByExample")
    long countByExample(DocUserVersionExample example);

    @DeleteProvider(type=DocUserVersionSqlProvider.class, method="deleteByExample")
    int deleteByExample(DocUserVersionExample example);

    @Delete({
        "delete from doc_user_version",
        "where APP_ID = #{appId,jdbcType=INTEGER}",
          "and USER_ID = #{userId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(@Param("appId") Integer appId, @Param("userId") Integer userId);

    @Insert({
        "insert into doc_user_version (USER_ID, DEV_VERSION)",
        "values (#{userId,jdbcType=INTEGER}, #{devVersion,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="appId", before=false, resultType=Integer.class)
    int insert(DocUserVersion record);

    @InsertProvider(type=DocUserVersionSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="appId", before=false, resultType=Integer.class)
    int insertSelective(DocUserVersion record);

    @SelectProvider(type=DocUserVersionSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="APP_ID", property="appId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="USER_ID", property="userId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="DEV_VERSION", property="devVersion", jdbcType=JdbcType.INTEGER)
    })
    List<DocUserVersion> selectByExample(DocUserVersionExample example);

    @Select({
        "select",
        "APP_ID, USER_ID, DEV_VERSION",
        "from doc_user_version",
        "where APP_ID = #{appId,jdbcType=INTEGER}",
          "and USER_ID = #{userId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="APP_ID", property="appId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="USER_ID", property="userId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="DEV_VERSION", property="devVersion", jdbcType=JdbcType.INTEGER)
    })
    DocUserVersion selectByPrimaryKey(@Param("appId") Integer appId, @Param("userId") Integer userId);

    @UpdateProvider(type=DocUserVersionSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") DocUserVersion record, @Param("example") DocUserVersionExample example);

    @UpdateProvider(type=DocUserVersionSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") DocUserVersion record, @Param("example") DocUserVersionExample example);

    @UpdateProvider(type=DocUserVersionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DocUserVersion record);

    @Update({
        "update doc_user_version",
        "set DEV_VERSION = #{devVersion,jdbcType=INTEGER}",
        "where APP_ID = #{appId,jdbcType=INTEGER}",
          "and USER_ID = #{userId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DocUserVersion record);
}